package com.ylb.rent.service.impl;

import java.util.List;
import java.util.stream.Collectors;

import com.ylb.rent.dao.ApartmentFeetypeMapper;
import com.ylb.rent.entity.ApartmentFeetype;
import com.ylb.rent.entity.ApartmentStuff;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 import com.ylb.rent.dao.FeetypeMapper;
import  com.ylb.rent.entity.Feetype;
import com.ylb.rent.service.IFeetypeService;

/**
 * 费用类型Service业务层处理
 * 
 * @author ylb
 * @date 2023-06-29
 */
@Service
public class FeetypeServiceImpl implements IFeetypeService 
{
    @Autowired
    private FeetypeMapper feetypeMapper;


    @Autowired
    private ApartmentFeetypeMapper apartmentFeetypeMapper;
    @Override
    public List<Feetype> selectListByApartmentId(Long aId) {
        ApartmentFeetype selector = ApartmentFeetype.builder().apartmentId(aId).build();


        List<ApartmentFeetype> list = apartmentFeetypeMapper.selectApartmentFeetypeList(selector);
//        得到stuffId集合
        List<Long> idList = list.stream().map(ApartmentFeetype::getFeetypeId).collect(Collectors.toList());
        return feetypeMapper.selectBatchIds(idList);
    }

    /**
     * 查询费用类型
     * 
     * @param id 费用类型主键
     * @return 费用类型
     */
    @Override
    public Feetype selectFeetypeById(Long id)
    {
        return feetypeMapper.selectFeetypeById(id);
    }

    /**
     * 查询费用类型列表
     * 
     * @param feetype 费用类型
     * @return 费用类型
     */
    @Override
    public List<Feetype> selectFeetypeList(Feetype feetype)
    {
        return feetypeMapper.selectFeetypeList(feetype);
    }

    /**
     * 新增费用类型
     * 
     * @param feetype 费用类型
     * @return 结果
     */
    @Override
    public int insertFeetype(Feetype feetype)
    {
        return feetypeMapper.insertFeetype(feetype);
    }

    /**
     * 修改费用类型
     * 
     * @param feetype 费用类型
     * @return 结果
     */
    @Override
    public int updateFeetype(Feetype feetype)
    {
        return feetypeMapper.updateFeetype(feetype);
    }

    /**
     * 批量删除费用类型
     * 
     * @param ids 需要删除的费用类型主键
     * @return 结果
     */
    @Override
    public int deleteFeetypeByIds(Long[] ids)
    {
        return feetypeMapper.deleteFeetypeByIds(ids);
    }

    /**
     * 删除费用类型信息
     * 
     * @param id 费用类型主键
     * @return 结果
     */
    @Override
    public int deleteFeetypeById(Long id)
    {
        return feetypeMapper.deleteFeetypeById(id);
    }
}
